#ifndef PAINTERWIDGET_H
#define PAINTERWIDGET_H

#include <QWidget>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QPainter>
#include <QVector>
#include <QPoint>
#include <QToolBar>
#include <QAction>
#include <QPalette>
#include <QColor>
#include <QMenu>
#include <QFileDialog>
#include <QTextEdit>
#include <QPushButton>


class PainterWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PainterWidget(QWidget *parent = 0);
protected:
    void paintEvent(QPaintEvent *) override;//重写窗体重绘事件
    void mousePressEvent(QMouseEvent *) override;//重写鼠标按下事件
    void mouseReleaseEvent(QMouseEvent *) override;//重写鼠标释放事件
    void mouseMoveEvent(QMouseEvent *) override;//重写鼠标移动事件
    void keyPressEvent(QKeyEvent *e) override; //重写按键事件
    void dragEnterEvent(QDragEnterEvent* event) override; // 拓展进入事件
    void dropEvent(QDropEvent* event) override; // 拖拽事件

public:
private:
    int m_proc_cnt;
    int _lpress;//左键按下标志
    int _openflag;//打开图片
    QPixmap _pixmap;//画布图片
    QPushButton *m_check_btn;
public:
    QVector<QVector<QPoint> > _lines;//线条集合(一条线条可包含多个线段)
    QVector<int>  _shape;//图形类型集合，用于撤回功能
    QPoint _begin;//鼠标按下坐标、用于最后一个图形移动
signals:

public slots:
    QString SavePic();//保存图片
    bool OpenPic(const QString &path = "");//打开图片
};

#endif // PAINTERWIDGET_H
